#!/usr/bin/env python
''' The Wepye configures '''

import re

class Wepye_Config:
    def __init__(self, config_file):
        self.file = config_file
        self.config = {}
        self._read_configure()
    def configs(self):
        return self.config.keys()
    def _read_configure(self):
        try:
            F = open(self.file, "r")
        except IOError, (errno, strerror):
            print "I/O error(%s): %s" % (errno, strerror)
            return
        while True:
            try:
                line = F.next()
            except:
                return
            m = re.match('\s*(\S*)\s*=\s*["\'](\S*)["\']', line)
            if not m:
                continue
            self.config[m.group(1)] = []
            for p in str(m.group(2)).split(','):
                if p != ',' and len(p):
                    self.config[m.group(1)].append(p)
    def display_config(self):
        for key in self.config.keys():
            print "Key: " + str(key)
            for value in self.config[key]:
                print "V: "+ str(value)



if __name__ == '__main__':
    config = Wepye_Config('../etc/wepye.conf')
    config.display_config()


